import style from "./RadioGroup.module.css";

type RadioGroupProps = {
  value: any;
  name: string;
  options: { label: string; value: any }[];
  onChange: (select: any) => void;
};

export function RadioGroup(props: RadioGroupProps) {
  const { value, name, options, onChange } = props;
  return (
    <div className={style.radioGroup}>
      {options.map((option) => (
        <button key={option.value} className={style.radioGroupItem}>
          <label>
            {option.label}
            <input
              type="radio"
              value={option.value}
              checked={value === option.value}
              name={name}
              onChange={() => onChange(option.value)}
            />
          </label>
        </button>
      ))}
    </div>
  );
}
